import { BaseSpriteToolTip } from "../../common/tooltip/BaseSpriteToolTip";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ImagesConst } from "../../../resource/ImagesConst";
import { FashionJewelTargetTipsPart } from "./FashionJewelTargetTipsPart";
import { AutoFeedCheckBoxSprite } from "../../autoFeed/AutoFeedCheckBoxSprite";
import { StrengthAddConfig } from "../../../resource/StrengthAddConfig";
import { Cache } from "../../../cache/Cache";
import { WardrobeCache } from "../../../cache/WardrobeCache";
import { FashionBoxUtil } from "../FashionBoxUtil";
//class FashionJewelTargetTips
    
    export  class FashionJewelTargetTips extends BaseSpriteToolTip
    {
        constructor()
        {
            super();
            this._arr = [];
            this.intiView();
            return;
        }

        /* internal  */intiView(): void
        {
            var loc1=ObjCreate.createGTextField(Language.getString(74610), 63, 3, 84, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createBg(10, 27, 130, 1, this, ImagesConst.SeptalLine);
            this._curTarget = new FashionJewelTargetTipsPart();
            this._curTarget.x = 10;
            this._curTarget.y = 26;
            addChild(this._curTarget);
            this._nextLV = ObjCreate.createGTextField(Language.getString(79024), 10, 68, 55, 20, this);
            this._downSp = new AutoFeedCheckBoxSprite();
            this._downSp.x = 10;
            this._downSp.y = 20;
            addChild(this._downSp);
            this._nextTarget = new FashionJewelTargetTipsPart();
            this._downSp.addChild(this._nextTarget);
            this._desTx = ObjCreate.createGTextField("", 0, 20, 200, 20, this, GlobalStyle.textFormat2);
            return;
        }

        public /* override */ set tooltipData(arg1)
        {
            var loc3=0;
            var loc4=false;
            var loc5=0;
            var loc6=0;
            var loc7=0;
            var loc10=null;
            var loc11=null;
            var loc12=0;
            var loc13=0;
            super.tooltipData = arg1;
            this._arr = arg1 as Array<any>;
            var loc1=StrengthAddConfig.instance.fashionJewelTargetArr.length;
            var loc2=this._arr.length;
            var loc8=0;
            var loc9=0;
            while (loc9 < loc1) 
            {
                loc6 = StrengthAddConfig.instance.fashionJewelTargetArr[loc9];
                loc8 = 0;
                loc12 = 0;
                while (loc12 < loc2) 
                {
                    if ((loc7 = this._arr[loc12]) >= loc6) 
                    {
                        ++loc8;
                    }
                    ++loc12;
                }
                if (loc8 != loc2) 
                {
                    if (loc9 == 0) 
                    {
                        loc3 = 0;
                        loc4 = false;
                        loc5 = 0;
                    }
                    break;
                }
                else 
                {
                    loc3 = loc6;
                    loc4 = true;
                    loc5 = loc9;
                }
                ++loc9;
            }
            if (loc4) 
            {
                if (loc3 == StrengthAddConfig.instance.fashionJewelTargetArr[(loc1 - 1)]) 
                {
                    (loc10 = StrengthAddConfig.instance.getFashionJewelTargetDic(loc6, Cache.instance.role.entityInfo.career)).isOpen = true;
                    loc10.targetLv = loc3;
                    loc10.openNum = WardrobeCache.FASHIONJEWELHOLE;
                    this._curTarget.updateInfo(loc10, WardrobeCache.FASHIONJEWELHOLE);
                    this._downSp.visible = false;
                }
                else 
                {
                    (loc10 = StrengthAddConfig.instance.getFashionJewelTargetDic(loc3, Cache.instance.role.entityInfo.career)).isOpen = true;
                    loc10.targetLv = loc3;
                    loc10.openNum = WardrobeCache.FASHIONJEWELHOLE;
                    this._curTarget.updateInfo(loc10, WardrobeCache.FASHIONJEWELHOLE);
                    loc13 = StrengthAddConfig.instance.fashionJewelTargetArr[loc5 + 1];
                    (loc11 = StrengthAddConfig.instance.getFashionJewelTargetDic(loc13, Cache.instance.role.entityInfo.career)).isOpen = false;
                    loc11.targetLv = loc13;
                    loc11.openNum = FashionBoxUtil.getTargetFitNum(this._arr, loc13);
                    this._nextTarget.updateInfo(loc11, WardrobeCache.FASHIONJEWELHOLE);
                    this._downSp.visible = true;
                    this._desTx.htmlText = Language.getStringByParam(74612, WardrobeCache.FASHIONJEWELHOLE, loc13, loc13);
                }
            }
            else 
            {
                loc6 = StrengthAddConfig.instance.fashionJewelTargetArr[0];
                (loc10 = StrengthAddConfig.instance.getFashionJewelTargetDic(loc6, Cache.instance.role.entityInfo.career)).isOpen = false;
                loc10.targetLv = loc6;
                loc10.openNum = FashionBoxUtil.getTargetFitNum(this._arr, loc6);
                this._curTarget.updateInfo(loc10, WardrobeCache.FASHIONJEWELHOLE);
                this._downSp.visible = false;
            }
            this.setSize();
            return;
        }

        /* internal  */setSize(): void
        {
            if (this._downSp.visible) 
            {
                this._nextLV.y = this._curTarget.y + this._curTarget.height;
                this._downSp.y = this._nextLV.y + 18;
                this._desTx.y = this._downSp.y + this._nextTarget.height + 3;
            }
            else 
            {
                this._nextLV.y = 0;
                this._downSp.y = 0;
                this._desTx.y = 0;
            }
            this._desTx.visible = this._downSp.visible;
            this._nextLV.visible = this._downSp.visible;
            return;
        }

        public /* override */ get height(): number
        {
            var loc1=0;
            if (this._downSp.visible) 
            {
                loc1 = this._desTx.y + 25;
            }
            else 
            {
                loc1 = this._curTarget.y + this._curTarget.height;
            }
            return loc1;
        }

        /* internal */ /* var */_downSp: AutoFeedCheckBoxSprite;

        /* internal */ /* var */_curTarget: FashionJewelTargetTipsPart;

        /* internal */ /* var */_nextTarget: FashionJewelTargetTipsPart;

        /* internal */ /* var */_nextLV: Object /* flash.text.TextField */;

        /* internal */ /* var */_arr: Array<any>;

        /* internal */ /* var */_desTx: Object /* flash.text.TextField */;
    }
